<template>
	<view>
		<u-sticky>
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="sectionChange"></u-tabs>
			<scan></scan>
			<scanner></scanner>
			<sm></sm>
			<honeywell></honeywell>
			<hk></hk>
			<!-- <view v-html="'累计选择体积：'+totalVolume" class="weikaishi3 lanse margin-zdy" v-if="current == 0"></view> -->
			<view class=" u-p-r-30 u-p-l-30 margin-zdy" v-if="current == 0 && mendianShow">
				<u-input v-model="operateName" placeholder="选择项目" type="select" @click="getO()" />
				<u-input v-model="setMentiontime" placeholder="选择日期" type="select" @click="getT()" />
				<u-search placeholder="请输入关键词搜索" :clearabled="true" v-model="keyword" border-color="#606266"
					@custom="search" @search="search"></u-search>
			</view>
		</u-sticky>
		<u-card padding="16" v-for="(item,index) in dataList" :key="index" v-if="current == 0 && mendianShow">
			<view class="" slot="head" @click="headClick(item)">
				<view class="wrap">
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi3">
								{{item.getUnit}}
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi5">
								<span>
									<u-icon name="map" size="29" labelSize="14px" labelColor="#00c300" label="地址">
									</u-icon>：{{item.getLocation}}
								</span>
							</view>
						</u-col>
					</u-row>
					<u-row v-if="item.stockPort">
						<u-col span="12" text-align="left">
							<view class="jinxingzhong">
								<span>备货口：{{item.stockPort}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row v-if="item.prePickOrderCount">
						<u-col span="6" text-align="left">
							<view class="jinxingzhong">
								<span>待拣货：{{item.prePickOrderCount}}单</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class="jinxingzhong">
								<span>待质检：{{item.preCheckOrderCount}}单</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="6" text-align="left">
							<view class="weikaishi4">
								<span>线路：{{item.lineName}}</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class="weikaishi4">
								<span>公里数：{{item.kilometer}}</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class="weikaishi4">
								<span>总体积：{{item.totalVolume}}</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class="weikaishi4">
								<span>总数量：{{item.totalNum}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
		</u-card>
		<u-card padding="16" v-if="current == 0 && !mendianShow">
			<view class="" slot="body">
				<view class="wrap">
					<view v-for="(item2,index2) in dataItemList" :key="index2">
						<u-row>
							<u-col span="9" text-align="left">
								<view class="weikaishi4">
									<u-checkbox :name="item2.transportNumber" v-model="dataItemList[index2].checked"
										iconColor="#000000" labelColor="#000000" @change="checkboxOrder">
										{{item2.orders}}.单号：{{item2.customerOrder}}</u-checkbox>
								</view>
							</u-col>
							<u-col span="3" text-align="right" v-if="item2.setMentiontime != setMentiontime">
								<view class="u-m-t-4">
									<u-tag text="甩货" type="error" shape="circle"></u-tag>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col span="1" text-align="center">
								<view class=" u-m-t-4 weikaishi6">
									<span></span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="weikaishi3">
									<span>
										<u-icon name="calendar" size="30" labelSize="14px" labelColor="#000000"
											label="日期" color="#000000"></u-icon>：{{item2.setMentiontime}}
									</span>
								</view>
							</u-col>
							<u-col span="5" text-align="left">
								<view class="weikaishi3">
									<span>
										<u-icon name="pushpin" size="30" labelSize="14px" labelColor="#000000"
											label="备货口" color="#000000"></u-icon>：{{item2.stockPort}}
									</span>
								</view>
							</u-col>
							<u-col span="1" text-align="center">
								<view class="u-m-t-4 weikaishi6">
									<span></span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="u-m-t-4 weikaishi3">
									<span>
										<u-icon name="clock" size="30" labelSize="14px" labelColor="#000000" label="体积"
											color="#000000"></u-icon>：{{item2.totalVolume}}m³
									</span>
								</view>
							</u-col>
							<u-col span="5" text-align="left">
								<view class="u-m-t-4 weikaishi3">
									<span>
										<u-icon name="clock" size="30" labelSize="14px" labelColor="#000000" label="数量"
											color="#000000"></u-icon>：{{item2.totalNum}}
									</span>
								</view>
							</u-col>
							<u-col span="12" text-align="right" v-if="xlbClientId == null || xlbClientId == ''">
								<view class="u-m-t-4 u-line-1">
									<span>
										<u-button type="primary" plain="true" size="default" @click="showpopup(item2)">
											拆明细</u-button>
									</span>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col span="12" text-align="right">
								<view class="jiange">
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
				<u-button @click="mxfh()">返回</u-button>
			</view>
		</u-card>
		<u-card padding="16" v-for="(item,index) in yifayun" :key="index" v-if="current == 1">
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="5" text-align="center">
							<view class="u-line-1">
								<u-icon name="car-fill" :label="item.carnumbger" label-size="33" label-color="#19be6b"
									color="#19be6b" size="45"></u-icon>
							</view>
						</u-col>
						<u-col span="4" text-align="center">
							<view class="u-line-1 u-m-t-5">
								<span>{{item.privatecarType}}</span>
							</view>
						</u-col>
						<u-col span="3" text-align="center">
							<view class="u-line-1 u-m-t-5">
								<span>{{item.driver1}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="u-line-1 weikaishi4">
								<span>调度时间：{{item.createTime}}</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class=" u-m-t-2 weikaishi4">
								<span>总体积：{{item.tooDeployVolume}}m³</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class=" u-m-t-2 weikaishi4">
								<span>总件数：{{item.tooDeployNum}}</span>
							</view>
						</u-col>
						<u-col span="12" text-align="right">
							<view class="u-line-1 u-m-t-5" v-if="item.zhuangzaiFileid"
								@click="viewImage(item.zhuangzaiFileid)">
								<u-icon name="file-text" label="装载照片" label-color="#2b85e4" color="#2b85e4" size="30">
								</u-icon>
							</view>
							<view class="u-line-1 u-m-t-5" v-else @click="uploadimg(item.dispatchNumber)">
								<u-icon name="file-text" label="装载照片未传" label-color="#e84d74" color="#e84d74" size="30">
								</u-icon>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="" slot="body">
				<view class="wrap">
					<u-row>
						<u-col span="12" text-align="center">
							<view class="u-line-1">
								<u-line-progress active-color="#19be6b" :striped="true"
									:percent="(item.tooDeployVolume/item.privatecarSurevolume*100).toFixed(1)"
									:striped-active="true"></u-line-progress>
							</view>
						</u-col>
					</u-row>
					<view v-for="(item1,index1) in item.list" :key="index1">
						<u-row>
							<u-col span="9" text-align="left">
								<view class="weikaishi4">
									<span>{{item1.getUnit}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="right" v-if="item1.sfsale > 0">
								<view class="">
									<u-tag text="有甩货" type="error" shape="circle"></u-tag>
								</view>
							</u-col>
							<u-col span="12" text-align="left">
								<view class="weikaishi5">
									<span>
										<u-icon name="map" size="29" labelSize="14px" labelColor="#00c300" label="地址">
										</u-icon>：{{item1.getLocation}}
									</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left" v-if="item1.prePickOrderCount">
								<view class="jinxingzhong">
									<span>待拣货：{{item1.prePickOrderCount}}单</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left" v-if="item1.preCheckOrderCount">
								<view class="jinxingzhong">
									<span>待质检：{{item1.preCheckOrderCount}}单</span>
								</view>
							</u-col>
							<u-col span="4" text-align="left">
								<view class="weikaishi4">
									<span>线路：{{item1.lineName}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="left">
								<view class="weikaishi4">
									<span>公里数：{{item1.kilometer}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="left">
								<view class="weikaishi4">
									<span>备货口：{{item1.stockPort}}</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="u-line-1 u-m-t-2">
									<span>体积{{item1.tooVolume}}m³</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="u-line-1 u-m-t-2">
									<span>件数{{item1.totalNum}}</span>
								</view>
							</u-col>
							<u-col span="12" text-align="right">
								<view class="jiange">
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</view>
			<view class="foot-butten" slot="foot">
				<view :class="flex">
					<u-col span="4" text-align="center" @click="chexiaod(item.dispatchNumber)">
						<view class="u-m-10 u-border-right">
							撤销
						</view>
					</u-col>
					<u-col span="4" text-align="center" @click="tooCarsy(item.dispatchNumber)">
						<view class="u-m-10 u-border-right">
							编辑
						</view>
					</u-col>
					<u-col span="4" text-align="center" @click="uploadimg(item.dispatchNumber)">
						<view class="u-m-10">
							装载拍照
						</view>
					</u-col>
				</view>
			</view>
		</u-card>
		<u-popup v-model="show" mode="center" closeable width="680rpx" height="800rpx" border-radius="10">
			<view class="u-text-center u-m-t-20 weikaishi3">
				<u-icon name="order" size="30" labelSize="15px" labelColor="#000000" :label="'单号：'+showcustomerOrder">
				</u-icon>
			</view>
			<view class="u-text-left u-m-t-2 weikaishi3 lanse margin-zdy" v-html="'选择体积：'+goodsVolume"></view>
			<u-card padding="16" v-for="(item,index) in dataList2" :key="index">
				<view class="" slot="head">
					<view class="wrap">
						<u-row>
							<u-col span="12">
								<view class="weikaishi3 lanse">
									<u-checkbox :name="dataList2[index].id" v-model="dataList2[index].checked"
										@change="checkboxGoods">{{item.goodsName}}</u-checkbox>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
				<view class="" slot="body">
					<view class="wrap">
						<u-row>
							<u-col span="3" text-align="center">
								<view class="weikaishi u-m-t-10">
									<span>体积</span>
								</view>
							</u-col>
							<u-col span="2" text-align="center">
								<view class="weikaishi u-m-t-10">
									<span>数量</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center">
								<view class="weikaishi u-m-t-10 lanse">
									<span>配置体积</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center">
								<view class="weikaishi u-m-t-10 lanse">
									<span>配置数</span>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col span="3" text-align="center">
								<view class="u-m-t-10 weikaishi4">
									<span>{{item.notvolume}}</span>
								</view>
							</u-col>
							<u-col span="2" text-align="center">
								<view class="u-m-t-10 weikaishi4">
									<span>{{item.notnum}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center">
								<view class="u-m-t-10 weikaishi4">
									<span>{{item.shuruVolume}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center">
								<view class="u-m-t-2 weikaishi6 yiwancheng">
									<span>
										<u-input v-model="dataList2[index].shurunum" type="digit" border="true"
											height="50" placeholder=" " @focus="chaidanfocus(item.id)"
											@input="chaidaninput" />
									</span>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</u-card>
			<view style="height: 80rpx;text-align: center;">
				<view class="close-btn u-m-t-40">
					<u-button size="medium" @click="define()">确定</u-button>
				</view>
			</view>
		</u-popup>

		<u-popup v-model="show7" mode="center" closeable width="650rpx" height="850rpx" border-radius="10">
			<view class="u-text-left u-m-t-20 weikaishi2 yiwancheng" style="margin-left: 20rpx;">待配置确认车辆</view>
			<view class="wrap">
				<view style="background-color: #eaeaea;" v-for="(item,index) in zhuijiacarlist" :key="index"
					@click="zhuijiacar(item.dispatchNumber)">
					<u-row>
						<u-col span="5" text-align="center">
							<view class="u-line-1 u-m-t-10">
								<u-icon name="car-fill" :label="item.carnumbger" label-size="33" label-color="#19be6b"
									color="#19be6b" size="45"></u-icon>
							</view>
						</u-col>
						<u-col span="4" text-align="center">
							<view class="u-line-1 u-m-t-10">
								<span>{{item.privatecarType}}</span>
							</view>
						</u-col>
						<u-col span="3" text-align="center">
							<view class="u-line-1 u-m-t-10">
								<span>{{item.driver1}}</span>
							</view>
						</u-col>
						<u-col span="12" text-align="center">
							<view class="u-line-1 u-m-t-2">
								<u-line-progress active-color="#19be6b" :striped="true"
									:percent="(item.tooDeployVolume/item.privatecarSurevolume*100).toFixed(1)"
									:striped-active="true"></u-line-progress>
							</view>
						</u-col>
						<u-col span="6" text-align="center">
							<view class=" u-m-t-2 weikaishi4">
								<span>体积：{{item.tooDeployVolume}}m³</span>
							</view>
						</u-col>
						<u-col span="6" text-align="center">
							<view class=" u-m-t-2 weikaishi4">
								<span>件数：{{item.tooDeployNum}}</span>
							</view>
						</u-col>
						<u-col span="12" text-align="left">
							<view class=" u-m-t-2 weikaishi4">
								<span>调度时间：{{item.createTime}}</span>
							</view>
						</u-col>
					</u-row>
					<view v-for="(item1,index1) in item.list" :key="index1">
						<u-row>
							<u-col span="12" text-align="left">
								<view class="u-m-t-2 weikaishi4">
									<span>收货单位：{{item1.getUnit}}</span>
								</view>
							</u-col>
							<u-col span="12" text-align="left">
								<view class="weikaishi5">
									<span>
										<u-icon name="map" size="29" labelSize="14px" labelColor="#00c300" label="地址">
										</u-icon>：{{item1.getLocation}}
									</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="weikaishi4">
									<span>线路：{{item1.lineName}}</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="weikaishi4">
									<span>公里数：{{item1.kilometer}}</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="u-line-1 u-m-t-2">
									<span>体积{{item1.tooVolume}}m³</span>
								</view>
							</u-col>
							<u-col span="6" text-align="left">
								<view class="u-line-1 u-m-t-2">
									<span>件数{{item1.totalNum}}</span>
								</view>
							</u-col>
							<u-col span="12" text-align="right">
								<view class="u-m-t-15 u-line-1">
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</view>
		</u-popup>
		<view style="height: 90rpx;" v-if="current == 0">
		</view>
		<view v-if="current == 0" class="wrap"
			style="position: fixed;bottom: 0rpx;width: 100%;background-color: #2979ff;z-index: 999;">
			<u-line color="#bababa" />
			<u-row v-if="peizhilist.length == 0">
				<u-col span="12" text-align="center" @click="queren()">
					<view class="u-line-1 u-m-t-10 baise">
						装车
					</view>
				</u-col>
			</u-row>
			<u-row v-else>
				<u-col span="12" text-align="center" @click="zhuijia()">
					<view class="u-line-1 u-m-t-10 baise">
						追加明细
					</view>
				</u-col>
			</u-row>
		</view>
		<view>
			<u-calendar v-model="show8" mode="date" max-date="2070-01-01" @change="changesetMentiontime"></u-calendar>
		</view>
		<view>
			<u-select v-model="show2" :list="olist" @confirm="confirm"></u-select>
		</view>
		<u-popup v-model="show9" mode="center" closeable width="610rpx" height="460rpx" border-radius="10">
			<view class="u-text-center u-m-t-20">装车确认</view>
			<view class=" u-m-20">
				<u-row>
					<u-col span="3" text-align="center">
						<view class="u-m-t-10">
							<span>装车方:</span>
						</view>
					</u-col>
					<u-col span="9" text-align="center">
						<view class="">
							<u-radio-group v-model="loadingType">
								<u-radio @change="radioChange1" v-for="(item, index) in type1list" :key="index"
									:name="item.name">
									{{item.name}}
								</u-radio>
							</u-radio-group>
						</view>
					</u-col>
				</u-row>
			</view>
			<view class=" u-m-20" v-if="loadingType == '仓库'">
				<u-row>
					<u-col span="3" text-align="center">
						<view class="u-m-t-10">
							<span>装卸工号:</span>
						</view>
					</u-col>
					<u-col span="9" text-align="center">
						<view class="">
							<u-input v-model="loadingNumber" type="test" border="true" placeholder="请输入工号英文,隔开" />
						</view>
					</u-col>
				</u-row>
			</view>
			<view style="height: 80rpx">
				<view class="close-btn u-m-t-40">
					<u-button size="medium" @click="queren2()">确定</u-button>
				</view>
			</view>
		</u-popup>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
	import bmap from '../../../static/js/bmap-wx.js'
	import config from '../../../config.js'
	import scan from "@/components/uni-scan/scan.vue"
	import scanner from "@/components/uni-scan/scanner.vue"
	import sm from "@/components/uni-scan/sm.vue"
	import honeywell from "@/components/uni-scan/honeywell.vue"
	import hk from "@/components/uni-scan/hk.vue"

	export default {
		components: {
			scanner,
			scan,
			sm,
			honeywell,
			hk
		},
		data() {
			return {
				mendianShow: true,
				flex: '',
				list: [{
						name: '配置车辆'
					},
					{
						name: '待确认'
					},
				],
				current: 0,
				keyword: "",
				dataList: [],
				dataItemList: [],
				yifayun: [],

				zhuijiacarlist: [],

				dataList2: [],
				showcustomerOrder: '',
				list2: [],

				show: false,
				show2: false,
				show7: false,
				show8: false,
				show9: false,
				peizhilist: [],

				BMap: {},
				totalVolume: '',
				goodsVolume: 0,
				xuanzegoodsid: '',
				type1list: [{
						name: '仓库'
					},
					{
						name: '自装'
					}
				],
				loadingType: '仓库',
				loadingNumber: '',
				setMentiontime: '',
				operateId: '',
				operateName: '',
				olist: [],
				xlbClientId: '',
				getUnitId: '',
				getLocationId: '',
			}
		},
		onLoad() {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif

			let year = new Date().getFullYear(); //年
			let month = new Date().getMonth() + 1; //注意！月份是从0月开始获取的，所以要+1;
			let day = new Date().getDate(); //日
			this.setMentiontime = year + '-' + (month >= 10 ? month : '0' + month) + '-' + (day >= 10 ? day : '0' + day);

			// 新建百度地图对象 
			//#ifdef MP-WEIXIN
			this.BMap = new bmap.BMapWX({
				ak: 'ESWpVgDaBgDk7KWsgkUkBE6kzAN0BKTa'
			});
			//#endif

			this.$http.post('/rest/operate/findme', {}, {
				params: {},
				header: {
					'Authorization': uni.getStorageSync('token'),
				}
			}).then(res => {
				if (res.data.data != '' && res.data.data != null) {
					this.operateId = res.data.data.id
					this.operateName = res.data.data.operateName
				}
			})

			this.$http.post('/rest/operate/list3', {}, {
				params: {},
				header: {
					'Authorization': uni.getStorageSync('token'),
				}
			}).then(res => {
				for (let item1 of res.data.data) {
					let obj = {}
					obj.value = item1.id
					obj.label = item1.operateName
					this.olist.push(obj)
				}
			})

			this.findshifouyipeizhiByspec()
		},
		onShow() {
			this.findshifouyipeizhiByspec();
			this.refresh();
			let that = this
			uni.$off('scan')
			uni.$on('scan', function(res) {
				console.log('扫码结果：', res.codeStr);
				that.loadingNumber = res.codeStr

			})
			uni.$off('scanner') // 每次进来先 移除全局自定义事件监听器
			uni.$on('scanner', function(res) {
				console.log('扫码结果：', res.code);
				that.loadingNumber = res.code

			})
			uni.$off('sm') // 每次进来先 移除全局自定义事件监听器
			uni.$on('sm', function(res) {
				console.log('扫码结果：', res.code);
				that.loadingNumber = res.code

			})
			uni.$off('honeywell') // 每次进来先 移除全局自定义事件监听器
			uni.$on('honeywell', function(res) {
				console.log('扫码结果：', res.code);
				that.loadingNumber = res.code

			})
			uni.$off('hk') // 每次进来先 移除全局自定义事件监听器
			uni.$on('hk', function(res) {
				console.log('扫码结果：', res.code);
				that.loadingNumber = res.code

			})
		},
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		methods: {
			headClick(item) {
				this.xlbClientId = item.xlbClientId;
				this.mendianShow = false;
				this.getUnitId = item.getUnitId;
				this.getLocationId = item.getLocationId;
				this.getItemList();
			},
			getItemList() {
				this.$http.post('/rest/transport/getUnitMxList', {}, {
					params: {
						getUnitId: this.getUnitId,
						getLocationId: this.getLocationId,
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					this.dataItemList = res.data.data
				})
			},
			mxfh() {
				this.mendianShow = true;
				this.refresh();
			},
			findshifouyipeizhiByspec() {
				this.$http.post('/rest/transport/findshifouyipeizhiByspec', {}, {
					params: {
						operateId: this.operateId
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					this.peizhilist = res.data.data
				})
			},
			confirm(e) {
				this.operateId = e[0].value
				this.operateName = e[0].label
				this.refresh()
			},
			getO() {
				this.show2 = true
			},
			uploadimg(dispatchNumber) {
				uni.chooseImage({
					count: 1, //默认9
					sourceType: ['camera'],
					success: res1 => {
						var that = this
						uni.uploadFile({
							url: config.root + 'rest/transportCar/uploadzhuangzaiFile', // 文件上传路径
							filePath: res1.tempFilePaths[0],
							name: 'file',
							header: {
								'Authorization': uni.getStorageSync('token'),
							},
							formData: {
								dispatchNumber: dispatchNumber
							},
							success: res => {
								let data = JSON.parse(res.data);
								if (data.code == 200) {
									uni.showToast({
										title: '上传成功 '+ data.message,
										duration: 3000
									});
									setTimeout(() => {
										that.refresh()
									}, 500)
								} else {
									uni.showToast({
										title: data.message,
										duration: 2000,
										icon: 'none',
									});
								}
							}
						})
					}
				})
			},
			viewImage(fileId) {
				let arr = []
				let img = config.root + 'system/previewa/' + fileId
				arr.push(img)
				uni.previewImage({
					urls: arr,
				});
			},
			changesetMentiontime(e) {
				this.setMentiontime = e.result
				this.refresh()
			},
			getT() {
				this.show8 = true
			},
			radioChange1(e) {
				console.log(e)
				if (e == '自装') {
					this.loadingPersonnel = ''
				}
			},
			zhuijiacar(dispatchNumber) {
				uni.showModal({
					content: '确定追加吗？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '正在提交'
							})
							let gids = []
							let nums = []
							let orders = []
							let arrorders = []
							for (let item of this.list2) {
								if (item.goodId != '') {
									gids.push(item.goodId)
									nums.push(item.num)
									orders.push(item.transportNumber)
								} else {
									arrorders.push(item.transportNumber)
								}
							}
							this.$http.post('/rest/transport/batchassignDispatchNumber_driver?gids=' + gids +
								'&nums=' + nums + '&orders=' + orders + '&arrorders=' + arrorders, {}, {
									params: {
										dispatchNumber: dispatchNumber,
										operateId: this.operateId
									},
									header: {
										'Authorization': uni.getStorageSync('token'),
									}
								}).then(res => {
								uni.hideLoading()
								if (res.data.code == 200) {
									this.$refs.uToast.show({
										title: '操作成功',
										type: 'success'
									})
									setTimeout(() => {
										this.refresh()
									}, 500)
									this.list2 = []
									this.show7 = false
								} else {
									this.$refs.uToast.show({
										title: res.data.message,
										type: 'error'
									})
									setTimeout(() => {
										this.refresh()
									}, 500)
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			zhuijia() {
				if (this.list2.length > 0) {
					if (this.peizhilist.length == 1) {
						uni.showModal({
							content: '确定追加吗？',
							success: (res) => {
								if (res.confirm) {
									uni.showLoading({
										title: '正在提交'
									})
									let gids = []
									let nums = []
									let orders = []
									let arrorders = []
									for (let item of this.list2) {
										if (item.goodId != '') {
											gids.push(item.goodId)
											nums.push(item.num)
											orders.push(item.transportNumber)
										} else {
											arrorders.push(item.transportNumber)
										}
									}
									this.$http.post('/rest/transport/batchassignDispatchNumber_driver?gids=' +
										gids + '&nums=' + nums + '&orders=' + orders + '&arrorders=' +
										arrorders, {}, {
											params: {
												dispatchNumber: this.peizhilist[0].dispatchNumber,
												operateId: this.operateId
											},
											header: {
												'Authorization': uni.getStorageSync('token'),
											}
										}).then(res => {
										uni.hideLoading()
										if (res.data.code == 200) {
											this.$refs.uToast.show({
												title: '操作成功',
												type: 'success'
											})
											setTimeout(() => {
												this.refresh()
											}, 500)
											this.list2 = []
										} else {
											this.$refs.uToast.show({
												title: res.data.message,
												type: 'error'
											})
											setTimeout(() => {
												this.refresh()
											}, 500)
										}
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					} else {
						uni.showLoading({
							title: '加载中,默认4条'
						})
						this.$http.post('/rest/transport/findCarListBySpecTooZhuijia_driver4', {}, {
							params: {
								operateId: this.operateId
							},
							header: {
								'Authorization': uni.getStorageSync('token'),
							}
						}).then(res => {
							uni.hideLoading()
							this.zhuijiacarlist = res.data.data
						})
						this.show7 = true
					}
				} else {
					uni.showToast({
						title: "请勾选单号",
						icon: 'none'
					})
				}
			},
			tooCarsy(dispatchNumber) {
				this.$Router.push({
					name: 'checktooyedit',
					params: {
						dispatchNumber: dispatchNumber
					}
				})
			},
			chexiaod(dispatchNumber) {
				uni.showModal({
					content: '确定撤销吗？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '正在提交'
							})
							this.$http.post('/rest/transport/removeDispatchNumberBySpec', {}, {
								params: {
									dispatchNumber: dispatchNumber
								},
								header: {
									'Authorization': uni.getStorageSync('token'),
								}
							}).then(res => {
								uni.hideLoading()
								if (res.data.code == 200) {
									this.$refs.uToast.show({
										title: '操作成功',
										type: 'success'
									})
									setTimeout(() => {
										this.list2 = []
										// this.refreshGetUnitPage()
										this.refresh()
										this.findshifouyipeizhiByspec()
									}, 500)
								} else {
									this.$refs.uToast.show({
										title: res.data.message,
										type: 'error'
									})
									setTimeout(() => {
										this.refresh()
									}, 500)
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			queren2() {
				uni.showModal({
					content: '确定装入本车吗？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '正在提交'
							})
							let gids = []
							let nums = []
							let orders = []
							let arrorders = []
							for (let item of this.list2) {
								if (item.goodId != '') {
									gids.push(item.goodId)
									nums.push(item.num)
									orders.push(item.transportNumber)
								} else {
									arrorders.push(item.transportNumber)
								}
							}
							if (typeof this.loadingNumber != 'undefined' && this.loadingNumber != null && this
								.loadingNumber != "") {
								this.loadingNumber = this.loadingNumber.replaceAll('，', ',')
								this.loadingNumber = this.loadingNumber.replaceAll('.', ',')
								this.loadingNumber = this.loadingNumber.replaceAll('。', ',')
							}
							this.$http.post('/rest/transport/batchassign_driver?gids=' + gids + '&nums=' +
								nums + '&orders=' + orders + '&arrorders=' + arrorders, {}, {
									params: {
										loadingType: this.loadingType,
										loadingNumbers: this.loadingNumber,
										operateId: this.operateId
									},
									header: {
										'Authorization': uni.getStorageSync('token'),
									}
								}).then(res => {
								uni.hideLoading()
								this.show9 = false
								if (res.data.success) {
									if (res.data.message != null && res.data.message != '' && res.data
										.message != '请求成功') {
										uni.showModal({
											title: '提示',
											content: res.data.message,
											showCancel: false,
											success: (res) => {
												if (res.confirm) {
													// this.refreshGetUnitPage()
													this.refresh()
													this.list2 = []
												} else if (res.cancel) {
													console.log('用户点击取消');
												}
											}
										});
									} else {
										this.$refs.uToast.show({
											title: '操作成功',
											type: 'success'
										})
										setTimeout(() => {
											// this.refreshGetUnitPage()
											this.refresh()
										}, 500)
										this.list2 = []
										this.loadingNumber = ''
										this.findshifouyipeizhiByspec()
									}
								} else {
									this.$refs.uToast.show({
										title: res.data.message,
										type: 'error'
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			queren() {
				if (this.list2.length > 0) {
					if (this.operateId == '' || this.operateId == null) {
						uni.showToast({
							title: "请选择项目",
							icon: 'none'
						})
						return
					}
					this.show9 = true
				} else {
					uni.showToast({
						title: "请勾选单号或明细",
						icon: 'none'
					})
				}
			},
			checkboxOrder(e) {
				for (let item of this.dataList) {
					let yes = false
					for (let item1 of this.dataItemList) {
						if (item1.transportNumber == e.name) {
							item.checked = false
							yes = true
							let new_list = []
							if (e.value) {
								let obj = {}
								obj.transportNumber = item1.transportNumber
								obj.goodId = ''
								obj.num = ''
								obj.totalVolume = item1.totalVolume
								new_list.push(obj)
							}
							for (let item2 of this.list2) {
								if (item2.transportNumber != item1.transportNumber) {
									new_list.push(item2)
								}
							}
							this.list2 = new_list
							break
						}
					}
					if (yes) {
						break
					}
				}
				this.sumVolume()
			},
			sumVolume() {
				let totalVolume = 0
				for (let item3 of this.list2) {
					totalVolume += item3.totalVolume * 1
				}
				this.totalVolume = totalVolume.toFixed(3)
			},
			checkboxArr(e) {
				for (let item of this.dataList) {
					if (item.getLocationId == e.name) {
						for (let item2 of item.list) {
							let new_list = []
							if (e.value) {
								item2.checked = true
								let obj = {}
								obj.transportNumber = item2.transportNumber
								obj.goodId = ''
								obj.num = ''
								obj.totalVolume = item2.totalVolume
								new_list.push(obj)
							} else {
								item2.checked = false
							}
							for (let item3 of this.list2) {
								if (item3.transportNumber != item2.transportNumber) {
									new_list.push(item3)
								}
							}
							this.list2 = new_list
						}
					}
				}
				this.sumVolume()
			},
			checkboxGoods(e) {
				let falg = 0
				let goodsVolume = 0
				for (let item1 of this.dataList2) {
					if (item1.checked && item1.id != e.name) {
						if (parseFloat(item1.shuruVolume) > 0) {
							goodsVolume = (parseFloat(goodsVolume) + parseFloat(item1.shuruVolume)).toFixed(3)
							falg = 1
						}
					}
					if (e.value && item1.id == e.name) {
						if (parseFloat(item1.shuruVolume) > 0) {
							goodsVolume = (parseFloat(goodsVolume) + parseFloat(item1.shuruVolume)).toFixed(3)
							falg = 1
						}
					}
				}
				if (falg == 0) {
					this.goodsVolume = 0
				} else {
					this.goodsVolume = goodsVolume
				}
			},
			chaidanfocus(e) {
				this.xuanzegoodsid = e
			},
			chaidaninput(e) {
				for (let item2 of this.dataList2) {
					if (this.xuanzegoodsid == item2.id) {
						if (e == '') {
							item2.shuruVolume = 0
							this.sumgoods()
							return
						}
						if (typeof parseFloat(e) != 'number' || parseFloat(e) <= 0) {
							uni.showToast({
								title: "请输入正确数值",
								icon: 'none'
							})
							return
						}
						if (parseFloat(e) > parseFloat(item2.notnum)) {
							uni.showToast({
								title: "超出订单数量",
								icon: 'none'
							})
							return
						}
						item2.shuruVolume = (e * item2.goodsVolume).toFixed(3)
					}
				}
				this.sumgoods()
			},
			define() {
				let ifnull = true
				let mingxiorder = ''
				let new_list2 = []
				for (let item1 of this.dataList2) {
					if (item1.checked) {
						if (item1.shurunum == '') {
							uni.showToast({
								title: "请输入正确数值",
								icon: 'none'
							})
							return
						}
						if (typeof parseFloat(item1.shurunum) != 'number' || parseFloat(item1.shurunum) <= 0) {
							uni.showToast({
								title: "请输入正确数值",
								icon: 'none'
							})
							return
						}
						if (parseFloat(item1.shurunum) > parseFloat(item1.notnum)) {
							uni.showToast({
								title: "超出订单数量",
								icon: 'none'
							})
							return
						}
						if (mingxiorder == '') {
							mingxiorder = item1.transportNumber
						}
						if (ifnull) {
							ifnull = false
						}
						let obj = {}
						obj.num = item1.shurunum
						obj.transportNumber = item1.transportNumber
						obj.goodId = item1.goodId
						obj.totalVolume = (item1.shurunum * item1.goodsVolume).toFixed(3)
						new_list2.push(obj)
					}
				}
				if (ifnull) {
					uni.showToast({
						title: "请勾选商品信息",
						icon: 'none'
					})
				} else {
					for (let item2 of this.list2) {
						if (item2.transportNumber != mingxiorder) {
							new_list2.push(item2)
						}
					}
					this.list2 = new_list2

					this.sumVolume()
					this.show = false
				}
			},
			sumgoods() {
				let falg = 0
				let goodsVolume = 0
				for (let item1 of this.dataList2) {
					if (item1.checked) {
						if (parseFloat(item1.shuruVolume) > 0) {
							goodsVolume = (parseFloat(goodsVolume) + parseFloat(item1.shuruVolume)).toFixed(3)
							falg = 1
						}
					}
				}
				if (falg == 0) {
					this.goodsVolume = 0
				} else {
					this.goodsVolume = goodsVolume
				}
			},
			showpopup(item2) {
				this.showcustomerOrder = item2.customerOrder
				this.dataList2 = item2.list2
				this.sumgoods()
				this.show = true
			},
			refreshGetUnitPage() {
				// if(this.keyword == "" || this.keyword == null){
				// 	this.dataList = []
				// 	this.totalVolume = ''
				// } else {
				uni.showLoading({
					title: '加载中...'
				})
				this.$http.post('/rest/transport/getUnitList', {}, {
					params: {
						setMentiontime: this.setMentiontime,
						getUnit: this.keyword,
						operateIdc: this.operateId
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					uni.hideLoading()
					this.dataList = res.data.data
					this.totalVolume = ''
				})
				// }
			},
			refresh() {
				if (this.current == 0) {
					if (this.mendianShow) {
						this.refreshGetUnitPage();
					} else {
						this.getItemList();
					}
				} else if (this.current == 1) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$http.post('/rest/transport/findCarListBySpecToo_driver', {}, {
						params: {
							tstate: 'too'
						},
						header: {
							'Authorization': uni.getStorageSync('token'),
						}
					}).then(res => {
						uni.hideLoading()
						this.yifayun = res.data.data
					})
				}
			},
			sectionChange(e) {
				this.current = e
				if (this.current == 1) {
					uni.showLoading({
						title: '加载中...'
					})
					this.$http.post('/rest/transport/findCarListBySpecToo_driver', {}, {
						params: {
							tstate: 'too'
						},
						header: {
							'Authorization': uni.getStorageSync('token'),
						}
					}).then(res => {
						uni.hideLoading()
						this.yifayun = res.data.data
					})
				}
			},
			search(e) {
				this.refresh()
			},
		}
	}
</script>
<style lang="scss">
	.u-body-item {
		padding: 20rpx 15rpx;
	}

	.wrap {
		padding: 0rpx 12rpx;
	}

	.u-row {
		margin: 10rpx 2rpx;
	}

	.weikaishi2 {
		font-size: 34rpx;
	}

	.baise {
		background-color: #2979ff;
		color: #ffffff;
		font-size: 34rpx;
	}

	.margin-zdy {
		padding: 5rpx 20rpx 5rpx 30rpx;
		background-color: #FFFFFF;
	}

	.jiange {
		border-bottom: 1px solid #ebebeb;
	}
</style>
